/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package library.ucm;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import library.view.DeliveryDesk;

/**
 *
 * @author Donghui
 */
public class ShowDate {

    private static ShowDate local;
    private Date today;
    private String regDate;
    private String dateTemp;

    public static ShowDate getInstance()
    {
        if(local==null)
        {
            local=new ShowDate();
        }
        return local;
    }

    public void getRegDate()
    {
        today=new Date();
        SimpleDateFormat kiper=new SimpleDateFormat("yyyy-MM-dd");
        String tep=kiper.format(today);
        regDate=tep;
    }

    public String getExpDate()
    {
        try
        {
        this.getRegDate();
        Calendar startDate=Calendar.getInstance();
        today=new SimpleDateFormat("yyyy-MM-dd").parse(regDate);
        startDate.setTime(today);
        startDate.add(Calendar.WEEK_OF_MONTH, 2); //Offset 2 month
        Date endDate=startDate.getTime();
        SimpleDateFormat clar=new SimpleDateFormat("yyyy-MM-dd");
        dateTemp=clar.format(endDate);

//        DeliveryDesk.getInstance().getButtonModel().getRDate().setText(dateTemp);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return dateTemp;
    }
}
